package me.youline.dataServer.service.socialAction.event;

import me.youline.dataServer.entity.PublicMessage;


/**
 * 针对公告消息的社交行为事件，主要分为点赞事件与转发事件，事件的目标对象必须为操作的目标公告
 * @author linhan
 *
 */
public abstract class PubMsgSocialActionExeEvent extends AbstractSocialActionEvent implements SocialActionExeEvent {
	
	
	public PubMsgSocialActionExeEvent(Long processorId, PubMsgBaseInfo info) {
		super(processorId,info);
	}
	

	@Override
	public Long getTargetId() {
		PubMsgBaseInfo p = (PubMsgBaseInfo) this.getTargetObject();
		return p.getOriginId();
	}
	
	/**
	 * 公告消息数据，以作为表示事件的目标对象。它从公告消息（无论原创or转发）提取原创数据。
	 * @author linhan
	 *
	 */
	public static class PubMsgBaseInfo{
		
		private final Long creatorId;
		
		private final String msgPicUrl;
		
		private final Long originId;
		
		public PubMsgBaseInfo(Long originId, Long creatorId, String msgTitle, String msgPicUrl) {
			this.creatorId = creatorId;
			this.msgPicUrl = msgPicUrl;
			this.originId = originId;
		}
		
		public PubMsgBaseInfo(PublicMessage originMsg){
			this.creatorId = originMsg.getCreatorId();
			this.msgPicUrl = originMsg.getDisplayPicUrl();//原创公告的图片
			this.originId = originMsg.getId();
		}

		/**
		 * 获取公告创建人
		 * @return
		 */
		public Long getCreatorId() {
			return creatorId;
		}

		/**
		 * 获取公告略缩图
		 * @return
		 */
		public String getMsgPicUrl() {
			return msgPicUrl;
		}

		/**
		 * 获取原创消息ID
		 * @return
		 */
		public Long getOriginId() {
			return originId;
		}

	}
	
	
	/**
	 * 点赞社交行为事件
	 * @author linhan
	 *
	 */
	public static class PraiseSocialActionExeEvent extends PubMsgSocialActionExeEvent{

		public PraiseSocialActionExeEvent(Long processorId, PubMsgBaseInfo message) {
			super(processorId, message);
		}
		
		@Override
		public PubMsgBaseInfo getTargetObject() {
			return (PubMsgBaseInfo) super.getTargetObject();
		}
		
		
	}
}
